package com.yzy.fly.mapper;

import com.yzy.fly.entity.role.FlyViewWidget;
import com.yzy.fly.kernel.mapper.FlyBasicMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Collection;
import java.util.List;

@Mapper
public interface FlyViewWidgetMapper extends FlyBasicMapper<FlyViewWidget> {

    @Select("select * from fly_view_widget a where 1=1 ")
    List<FlyViewWidget> selectAllList();

    @Select("select * from fly_view_widget a where 1=1 and viewId = #{viewId} order by seq asc ")
    List<FlyViewWidget> selectAllByViewId(@Param("viewId")int viewId);

    /**
     * 批量插入（mysql）
     * @param entityList
     * @return
     */
    Integer insertBatchSomeColumn(Collection<FlyViewWidget> entityList);

    @Select("select * from fly_view_widget a where 1=1 and viewId = #{viewId} and systemId = #{systemId} order by parentId asc,seq asc ")
    List<FlyViewWidget> selectAllByViewIdAndSystemId(@Param("viewId") Integer viewId, @Param("systemId")Integer systemId);


    @Delete("delete a from fly_view_widget a where a.viewId = #{viewId}")
    int deleteByViewId(@Param("viewId")int viewId);


}
